<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>
        //当键盘按下松开时触发
        document.addEventListener('keyup', function () {
            console.log('我弹起来了');
        })

        // 可以识别功能键  例如 Ctrl 
        document.addEventListener('keydown', function () {
            console.log('我按下了');
        })
        //不懂识别功能键  例如 Ctrl 
        document.addEventListener('keypress', function () {
            console.log('我按下了');
        })
    </script>
</body>

</html>